﻿using System;
using System.Diagnostics;

namespace PlayTrace
{
    static class TestTraceSimple
    {
        /// <summary>
        /// messages written by Debug will only show in the IDE's debug output window
        /// </summary>
        private static void TestDebug()
        {
            Debug.WriteLine("****************** debug writes {0}", 1);
        }

        /// <summary>
        /// by default, messages writen by Trace will both appear in the IDE's debug output window
        /// and in the listeners attached
        /// it seems that "Debug output window" is the default listener
        /// </summary>
        private static void TestTrace()
        {
            // clear the default trace listeners (so no messages will be printed into Debug Output Window)
            Trace.Listeners.Clear();
            Trace.Listeners.Add(new ConsoleTraceListener());

            Trace.WriteLine(string.Format("****************** trace writes {0}", 2));
            Trace.TraceInformation("trace information");
            Trace.TraceWarning("trace warning");
            Trace.TraceError("trace error");

            Trace.WriteLineIf(true, "message shown");
            Trace.WriteLineIf(false, "!!!!!!!!!!! Messages Never Shown");
        }

        public static void TestMain()
        {
            TestDebug();
            TestTrace();
        }// TestMain
    }
}
